<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="<%=request.getContextPath()%>/image/LOGO.png" type="image/x-icon" />
<title>证件扫描</title>
</head>
<body>
<div class="easyui-panel" data-options="fit:true,border:0">
	<div  class="easyui-layout" style="width:100%;height:100%;">
			<div data-options="region:'north'" class="north-min" style="border-left:0px;text-align:center">
			   <span class="paddingTBL">
					<span id="scanning_PatientName" class="scanningHideItems"></span><span id="scanning_PatientIDCard" class="scanningHideItems"></span>
					<span id="scanning_fcydept" class="scanningHideItems"></span><span id="scanning_fcybs" class="scanningHideItems"></span>			
					<span id="scanning_fprn" class="scanningHideItems"></span><span id="scanning_fzyid" class="scanningHideItems"></span>
					<span id="scanning_frydate" class="scanningHideItems"></span><span id="scanning_fcydate" class="scanningHideItems"></span>
					<span id="scanning_ftimes" class="scanningHideItems"></span> <span id="scanning_DLRName" class="scanningHideItems"></span>
					<span id="scanning_DLRIDCard"></span><span id="scanning_contentName" class="scanningHideItems"></span>
					<span id="scanning_relation" class="scanningHideItems"></span><span id="scanning_content" class="scanningHideItems"></span>			
					<label>当前证件：</label>
					<select id="" class="easyui-combobox" name=""  >
						<option value="0" selected="selected">身份证</option>
	               		<option value="1" >工作证</option>
	               		<option value="2" >居住证</option>
	               		<option value="3" >港澳通行证</option>
		            </select>
					<a href="#" class="easyui-linkbutton" id="" onClick="printOpenDevice(PrintCammeraType.value)" style="">打开高拍仪</a>
					<span id="printShooting"><a href="#" class="easyui-linkbutton"  onClick="PrintCaptureToFile()" style="">拍 摄</a></span>
					<a href="#" class="easyui-linkbutton" onclick="PrintSetDeviceRotation(90)" >旋 转</a>&nbsp;&nbsp; 
					<a href="#" class="easyui-linkbutton" onclick="PrintSetDeviceRotation(180)" >上下旋转</a>&nbsp;&nbsp; 
					<a href="#" class="easyui-linkbutton" id="" onClick="openChargeDialog()" style="">收 费</a>
					<a href="#" class="easyui-linkbutton" id="" onClick="printPage()" style="">打 印</a>
					<!-- <a href="#" class="easyui-linkbutton" id="" onClick="" style="">返 回</a> -->
					<!-- 分辨率 -->
					<select id="printResolution" name="Resolution" style="display:none;" ></select>
					<textarea name="content" cols="30" rows="6" id="printContent" style="display:none;"></textarea>
					<input type="checkbox" name="PrintCheckReduceShadow" style="display:none;" id="PrintCheckReduceShadow" onclick="SetResuceShadow()"/>
				  	<!-- 标记为多页源 -->
					<input type="checkbox" style="display:none;" name="PrintcheckMultiSource" id="PrintcheckMultiSource"/>
					<label class="generalFont" style="display:none;">去除阴影</label>
					<label  class="generalFont" style="display:none;">文档变形修补</label>
					<select name="PrintCammeraType" id="PrintCammeraType" style="display:none;">
			          <option value ="0" selected="selected">文档摄像头</option>
			          <option value ="1">人像摄像头</option>
			          <option value ="2">双摄像头</option>
			        </select>
			     </span>
			</div>
			
			<div data-options="region:'west'" style="width:70%;" class="Cancel_borderLB">
				<div id="printCamero" style="width: 100%;height: 100%;" align="center">
					  <div style="width:100%;height:100%" align="center">
						<object id="printCapture" style ="width: 100%;height: 100%;" align="center" classid="clsid:9A73DB73-2CA3-478D-9A3F-7E9D6A8D327C">
						<!-- 如果要指定cab包和/或版本号参照以下示例 -->
						<!-- object id="Capture" style ="width: 99%;height: 550px;border: 5 gray solid;" align="middle" classid="clsid:9A73DB73-2CA3-478D-9A3F-7E9D6A8D327C" codebase="CaptureVideo.cab#version=1,7,8,0" -->
					    </object>
				      </div>
				</div>
			</div>
			
			<div data-options="region:'east',split:true" style="width:30%;" class="Cancel_borderLB">
			<!-- 	<ul id="picArea" oncontextmenu="onMenu(event)" style="height:100%;">
					<li style="height:36%;border: 1px solid #d4d4d4;border-top:0;"><img id="picture1" name="pic1" class="pic1" style=""/></li>
					<li style="height:36%;border: 1px solid #d4d4d4;border-top:0;"><img id="picture2" name="pic1" class="pic2" style=""/></li>
					<li style="height:36%;border: 1px solid #d4d4d4;border-top:0;"><img id="picture3" name="pic1" class="pic3" style=""/></li>
					<li style="height:36%;border: 1px solid #d4d4d4;border-top:0;"><img id="picture4" name="pic1" class="pic4" style=""/></li>
				</ul>
				<div id="PrintMenu" class="easyui-menu" style="width:120px;">
					<div onclick="repeatPicture(obj,claName)" data-options="">重 拍</div>
				</div> -->
			</div>
			
			<!-- 打印收费dialog -->
		    <div id="scanningCharge" class="easyui-dialog" data-options="closed:true">
			   <div  class="easyui-layout" style="width:660px;height:360px;">
					<div data-options="region:'west'" style="width:30%;height:310px;" class="Cancel_borderTL">
						<p class="headtags">患者信息 </p> 
						<p><label class="spanPaddwidth shootFontBold">病案号：</label><label class="dFprn"></label></p>
						<p><label class="spanPaddwidth shootFontBold">住院次数：</label><label class="dFtimes"></label></p>
						<p><label class="spanPaddwidth shootFontBold">姓名：</label><label class="dFname"></label></p>
						<p><label class="spanPaddwidth shootFontBold">出院日期：</label><label class="dFcydate"></label></p>
						<p><label class="spanPaddwidth shootFontBold">出院科室：</label><label class="dFcydept"></label></p>
					</div>
					<div data-options="region:'east'" style="width:70%;height:310px;margin-left:10px;" class="Cancel_borderTR">
						<p class="headtags">收费标准 </p>   
						    <table style="width:98%;" cellspacing="10">
								<tr>
									<td width="80px"><h4>打印内容</h4></td>
									<td>
										<label>病案首页</label>&nbsp;&nbsp; <label>出院小结</label>&nbsp;&nbsp;
										<label>入院病史</label>&nbsp;&nbsp; <label>入院记录</label>&nbsp;&nbsp;
										<label>病程记录病史</label>&nbsp;&nbsp; <label>术前小结</label>
									</td>
								</tr>
								<tr>
									<td class="shootFontBold">收费标准</td>
									<td>
										<select id="" class="easyui-combobox" name="" data-options="precision:2,width:120,height:24">
											<option value="0" selected="selected">按页收费</option>
											<option value="1">按张收费</option>
										</select>
									</td>
								</tr>
								<tr>
									<td class="shootFontBold">病历单价</td>
									<td>
									    <input id="singel" class="easyui-numberbox" data-options="width:120,height:24,min:1,panelHeight:'auto',readonly:false"/>
										<label>元</label>
									</td>
								</tr>
								<tr>
									<td class="shootFontBold">病历页数</td>
									<td>
									  <input id="printPage" class ="easyui-numberbox" data-options ="width:120,height:24,min:1,panelHeight:'auto',readonly:false"/>
								      <label>页</label>
									</td>
								</tr>
								<tr>
									<td class="shootFontBold">打印份数</td>
									<td>
									  <input id="printCopies" class ="easyui-numberbox" data-options ="width:120,height:24,min:1,panelHeight:'auto',readonly:false"/>
									  <label>份</label>
									</td>
								</tr>
						        <tr>
						           <td class="shootFontBold">总金额(￥)</td>
							       <td> 
							          <label id="ChargeTotal">元</label>
					 			   </td>
					 			</tr>
					 </table>
						
						 
				 </div>
			 </div>
		</div>
   </div>
</div>
   
<script type="text/javascript" src="<%=request.getContextPath()%>/js/Print/PrintScanning.js"></script>
<script type="text/javascript">
	 $("#scanning_PatientName").html(decodeURI('<%=request.getParameter("fname")%>'));
	 $("#scanning_PatientIDCard").html('<%=request.getParameter("fidcard")%>');
	 $("#scanning_fcydept").html(decodeURI('<%=request.getParameter("fcydept")%>'));
	 $("#scanning_fcybs").html(decodeURI('<%=request.getParameter("fcybs")%>'));
	 $("#scanning_fprn").html('<%=request.getParameter("fprn")%>');
	 $("#scanning_fzyid").html('<%=request.getParameter("fzyid")%>');
	 $("#scanning_frydate").html('<%=request.getParameter("frydate")%>');
	 $("#scanning_fcydate").html('<%=request.getParameter("fcydate")%>');
	 $("#scanning_ftimes").html('<%=request.getParameter("ftimes")%>');
	 $("#scanning_DLRName").html(decodeURI('<%=request.getParameter("dlrname")%>'));
	 $("#scanning_DLRIDCard").html('<%=request.getParameter("dlridcard")%>');
	 $("#scanning_relation").html('<%=request.getParameter("relation")%>');
	 $("#scanning_content").html('<%=request.getParameter("content")%>');
	 $("#scanning_contentName").html(decodeURI('<%=request.getParameter("contentName")%>'));
	$(function(){
		init();
		$("#printShooting").css("display","none");
		//屏蔽树节点区域浏览器自带右击事件
		$("#picArea").bind('contextmenu',function(){
			return false;
		});
	});
	function onMenu(event){
		 obj = event; //赋值给全局变量，以便重拍的时候调用
		var agent = navigator.userAgent.toLowerCase();
		if(agent.substring(0,11) == "mozilla/4.0"){ /*判断是否IE8*/
			claName = event.srcElement.className;
			//显示快捷菜单
			$("#PrintMenu").menu('show',{
				left:(event.screenX-30),
				top: (event.screenY-140)
			});
		}else{
			//显示快捷菜单
			$("#PrintMenu").menu('show',{
				left:event.pageX,
				top: event.pageY
			});
		}
	}
	
	//计算收费
	$("#singel,#printPage,#printCopies").numberbox({
		onChange:function(oldValue,newValue){
			figure();			
		}
	});
	
	//计算公式
	function figure(){
		var singel = $("#singel").numberbox("getValue");
		var page = $("#printPage").numberbox("getValue");
		var copies = $("#printCopies").numberbox("getValue");
		if(singel =="" || page =="" || copies ==""){
			return;
		}
		var total = "";
		total =parseInt(singel) * parseInt(page) * parseInt(copies);
		$("#ChargeTotal").html();
		$("#ChargeTotal").html(total +"&nbsp;元");
	}
	
	//打开打印页面
	function printPage(){
		//将信息放入缓存数组，以供打印页面填充数据
		if(images1){
			cacheImage.push(images1);
		}
		if(images2){
			cacheImage.push(images2);
		}
		if(images3){
			cacheImage.push(images3);
		}
		if(images4){
			cacheImage.push(images4);
		}
		cacheInfo.push($("#scanning_PatientName").text());
		cacheInfo.push($("#scanning_PatientIDCard").text());
		cacheInfo.push($("#scanning_fcydept").text());
		cacheInfo.push($("#scanning_fcybs").text());
		cacheInfo.push($("#scanning_fprn").text());
		cacheInfo.push($("#scanning_frydate").text());
		cacheInfo.push($("#scanning_fcydate").text());
		cacheInfo.push($("#scanning_relation").text());
		if($("#scanning_DLRName").text() != ""){
			cacheInfo.push($("#scanning_DLRName").text());
		}else if($("#scanning_DLRIDCard").text() != ""){
			cacheInfo.push($("#scanning_DLRIDCard").text());
		}
		var val = $("#scanning_content").text();
		var arr = [];
		arr  = val.split(",");
		for (var i = 0; i < arr.length; i++) {
			cacheContent.push(arr[i]);
		}
		window.open("Print/PrintPage");
	}
	
	//打开收费对话框
	function openChargeDialog(){
		$("#printCamero").css("display","none");
		$("#scanningCharge").dialog({
			maximizable:true,
			closed: false,
			modal: true,
			title: "打印收费",
			buttons:[{
				text:"保存",
				iconCls:'',
				handler:function(){
					var total = $("#ChargeTotal").text(); //总费用
					if(total == ""){
						$.messager.alert("info","请先计算出总费用在提交！","info");
						return;
					}
					var page = $("#printPage").numberbox("getValue"); //页数
					var copies = $("#printCopies").numberbox("getValue"); //份数
					var fzyid = $("#scanning_fzyid").text(); //住院ID
					$.ajax({
						url: ctx + '/Print/savePrintCharge',
						dataType:'json',
						type:'post',
						data:{
							"total" : total,
							"page" : page,
							"copies" : copies,
							"fzyid" : fzyid
						},
						success:function(data){
							if(data == true){
								$.messager.alert("info","操作成功！","info");
							}else{
								$.messager.alert("info","操作失败，请联系管理员！","info");
							}
						},
						error:function(){
							$.messager.alert("info","操作异常，请联系管理员！","info");
						}
					});
				}
			},{
				text:"取消",
				iconCls:'',
				handler:function(){
					 $("#singel").numberbox("setValue","");
					 $("#printPage").numberbox("setValue","");
					 $("#printCopies").numberbox("setValue","");
					 $("#ChargeTotal").html("");
					$('#scanningCharge').dialog("close");
					$("#printCamero").css("display","");
				}
			}],
			onClose:function(){
				$("#printCamero").css("display","block");	
			}
		});
		$(".dFprn").html($("#scanning_fprn").text());
		$(".dFtimes").html($("#scanning_ftimes").text());
		$(".dFname").html($("#scanning_PatientName").text());
		$(".dFcydate").html($("#scanning_fcydate").text());
		$(".dFcydept").html($("#scanning_fcydept").text());
		var conName = $("#scanning_contentName").text(); //打印内容
		var array = "";
		var html = "";
		array = conName.split(",");
		for (var i = 0; i < array.length; i++) {
			html += "<label>"+array[i]+"</label>&nbsp;&nbsp;";
		}
		$(".scanning_right").html(html);
	}
	
	
	//初始化高拍仪
	function init(){
		try{
			Content = document.getElementById("printContent");//获取文本框对象
			Capture = document.getElementById("printCapture");//根据js的脚本内容，必须先获取object对象
			ResSelect = document.getElementById("printResolution");//获取分辨率select标签的object对象
		}catch(err){
			alert("未找到ICaptureVideo.ocx控件，请重新安装!");
		}
	}
	
	 //键盘事件
    $(document).keydown(function (event) {
    	e = event ? event : (window.event ? window.event : null);
    	if(e.keyCode ==113){ //F12 按键
    		PrintCaptureToFile();
    	}
    });  
</script>
</body>
</html>